package cn.rulian.car.outbill.controller;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.rulian.base.auth.ann.Access;
import cn.rulian.base.auth.bo.User;
import cn.rulian.base.common.dto.UserInfo;
import cn.rulian.base.common.vo.Result;
import cn.rulian.car.outbill.service.OutBillService;
import cn.rulian.car.outbill.vo.OutBillVo;

/**
 * 车辆外出单--部门单据
 */

@Access(authCode="outBillOrgan")
@Controller
@RequestMapping("/car/outbill/outBillOrgan")
public class OutBillOrganController {
	
	@Autowired
	private OutBillService service;
	
	//private final Logger log = LoggerFactory.getLogger(getClass());
	
	private final String path="car/outbill/outbillOrgan_"; //页面基本路径

	/**
	 * 页面基本路径
	 */
	private String getPath()
	{
		return path;
	}
	
	/**
	 * 列表页面
	 */
	@RequestMapping("/listPage")
	public String listPage() {
		return this.getPath()+"list";
	}

	/**
	 * 查询
	 */
	@RequestMapping("/listData")
	@ResponseBody
	public Result listData(HttpSession session,OutBillVo vo) {
		//取当前用户
		UserInfo userInfo = UserInfo.getUserInfo(session); 
		User user = userInfo.getUser();
		return service.queryOrgan(vo,user.getOrgan().getAllCode());
	}

	/**
	 * 详情页面
	 */
	@RequestMapping("/detailPage")
	public String detailPage(Model model, Long id) {
		model.addAttribute("bo", service.findOne(id));
		return "car/outbill/outbillApply_detail";
	}
	
}
